package com.gzhryc.common.logging;

import java.util.Properties;

import com.gzhryc.common.kafka.JFKafkaProducer;
import com.gzhryc.common.kafka.procuder.MultipleKafkaProducer;
import com.gzhryc.common.kafka.procuder.SingleKafkaProducer;

public class LoggerConfigHelper {

	static LoggerConfigHelper me;

	public static LoggerConfigHelper self() {
		if (me == null) {
			me = new LoggerConfigHelper();
		}
		return me;
	}

	private JFKafkaProducer producer;
	private String kafkaTopic;

	public void setKafkaProducer(Properties properties) {
		String producerType = properties.getProperty("kafka.producerType", "single");
		if ("multiple".equals(producerType)) {
			String producerThreadNum = properties.getProperty("kafka.producerThreadNum", "2");
			producer = new MultipleKafkaProducer(properties, Integer.valueOf(producerThreadNum));
		} else {
			producer = new SingleKafkaProducer(properties);
		}
	}

	public void setKafkaTopic(String kafkaTopic) {
		this.kafkaTopic = kafkaTopic;
	}

	public String getKafkaTopic() {
		return kafkaTopic;
	}

	public JFKafkaProducer getKafkaProducer() {
		return producer;
	}
}
